package reflection;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Person {
    public Person(int age) {
        this.age = age;
    }
    private int age;

    private void sayHello() {
        System.out.println("hello world");
    }

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Class c = Class.forName("reflection.Person");
        c.getDeclaredMethod("sayHello").invoke(new Person(2));

    }
}
